﻿using UnityEngine;

namespace MyFramework
{
    public partial class TransformSimplify : MonoBehaviour
    {
        /// <summary>
        /// localPos的x轴设置
        /// </summary>
        /// <param name="transform"></param>
        /// <param name="x"></param>
        public static void SetLocalPosX(Transform transform,float x)
        {
            var localPos = transform.localPosition;
            localPos.x = x;
            transform.localPosition = localPos;
        }

        /// <summary>
        /// localPosition的Y轴设置
        /// </summary>
        /// <param name="transform"></param>
        /// <param name="y"></param>
        public static void SetLocalPosY(Transform transform,float y)
        {
            var localPos = transform.localPosition;
            localPos.y = y;
            transform.localPosition = localPos;
        }
        /// <summary>
        /// localPos的z轴设置
        /// </summary>
        /// <param name="transform"></param>
        /// <param name="z"></param>
        public static void SetLocalPosZ(Transform transform,float z)
        {
            var localPos = transform.localPosition;
            localPos.z = z;
            transform.localPosition = localPos;
        }
        /// <summary>
        /// localPos的xy轴设置
        /// </summary>
        /// <param name="transform"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        public static void SetLocalPosXY(Transform transform,float x,float y)
        {
            var localPos = transform.localPosition;
            localPos.x = x;
            localPos.y = y;
            transform.localPosition = localPos;
        }
        /// <summary>
        /// localPos的xz轴设置
        /// </summary>
        /// <param name="transform"></param>
        /// <param name="x"></param>
        /// <param name="z"></param>
        public static void SetLocalPosXZ(Transform transform,float x,float z)
        {
            var localPos = transform.localPosition;
            localPos.x = x;
            localPos.z = z;
            transform.localPosition = localPos;
        }
        /// <summary>
        /// localPos的yz轴设置
        /// </summary>
        /// <param name="transform"></param>
        /// <param name="y"></param>
        /// <param name="z"></param>
        public static void SetLocalPosYZ(Transform transform,float y,float z)
        {
            var localPos = transform.localPosition;
            localPos.y = y;
            localPos.z = z;
            transform.localPosition = localPos;
        }
        /// <summary>
        /// localPos的xyz轴设置
        /// </summary>
        /// <param name="transform"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="z"></param>
        public static void SetLocalPosXYZ(Transform transform,float x,float y,float z)
        {
            var localPos = transform.localPosition;
            localPos.x = x;
            localPos.y = y;
            localPos.z = z;
            transform.localPosition = localPos;
        }
        /// <summary>
        /// 坐标归一化
        /// </summary>
        /// <param name="transform"></param>
        public static void Identity(Transform transform)
        {
            transform.localPosition=Vector3.zero;
            transform.localScale=Vector3.zero;
            transform.localRotation=Quaternion.identity;
        }
    }
}

